<?php

class Contest
{
	
	protected $_id;
	protected $_name;
	protected $_event_id;
	protected $_privateE;
	protected $_creationDate;
	protected $_creator;
	protected $_comment;
	protected $_closed;
	
	public function __construct(array $donnees)
	{
		$this->hydrate($donnees);
	}
	
	public function hydrate(array $donnees)
	{
		foreach($donnees as $key => $value)
		{
			$method = 'set'. ucfirst($key);
			if(method_exists($this, $method))
			{
				$this->$method($value);
			}
		}
	}
	
	public function id(){ return $this->_id; }
	public function name(){ return $this->_name; }
	public function event_id(){ return $this->_event_id; }
	public function privateE(){ return $this->_privateE; }
	public function creationDate(){ return $this->_creationDate; }
	public function creator(){ return $this->_creator; }
	public function comment(){ return $this->_comment; }
	public function closed(){ return $this->_closed; }
	
	public function setId($id)
	{
		$id = (int) $id;
		if(is_int($id))
		{
			$this->_id = $id;
		}
	}
	public function setName($name)
	{
		$name = (string) $name;
		if(is_string($name))
		{
			$this->_name = $name;
		}
	}
	public function setEvent_id($event)
	{
		$event = (int) $event;
		if(is_int($event))
		{
			$this->_event_id = $event;
		}
	}
	public function setPrivateE($private)
	{
		$private = (bool) $private;
		if(is_bool($private))
		{
			$this->_privateE = $private;
		}
	}
	public function setCreationDate($creationDate)
	{
		$creationDate = (String) $creationDate;
		if(is_string($creationDate))
		{
			$this->_creationDate = $creationDate;
		}
	}
	public function setCreator($creator)
	{
		$creator = (int) $creator;
		if(is_int($creator))
		{
			$this->_creator = $creator;
		}
	}
	public function setComment($comment)
	{
		$comment = (string) $comment;
		if(is_string($comment))
		{
			$this->_comment = $comment;
		}
	}
	public function setClosed($closed)
	{
		if(is_int($closed))
		{
			$this->_closed = $closed;
		}
	}
		
}

?>